import { View } from '@tarojs/components';
import { useState, useEffect } from 'react';
import { getActivityList } from '@/service/apis/home';
import Taro from '@tarojs/taro';
import ActivityHeader from './component/ActivityHeader';
import ActivityList from './component/ActivityList';
import './index.scss';

const Activity = () => {
  const [list, setList] = useState([]);
  const getActivitys = async () => {
    try {
      const { data } = await getActivityList();
      setList(data.topic_list);
    } catch (err) {
      Taro.showToast({
        title: err?.message,
        icon: 'none',
      });
    }
  };

  useEffect(() => {
    getActivitys();
  }, []);
  return (
    <View className="activity-container">
      <ActivityHeader />
      <ActivityList activityList={list} />
    </View>
  );
};
export default Activity;
